package com.h2.ref.server.user;

import java.util.Map;

import org.springframework.dao.DataAccessException;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.security.core.userdetails.UsernameNotFoundException;

public class UserDetailsServiceInMem implements
      org.springframework.security.core.userdetails.UserDetailsService {
   
   private Map<String, UserDetails> _users;

   @Override
   public UserDetails loadUserByUsername(String username)
         throws UsernameNotFoundException, DataAccessException {
      return getUsers().get(username.toLowerCase());
   }

   /**
    * @return the users
    */
   public Map<String, UserDetails> getUsers() {
      return _users;
   }

   /**
    * @param users the users to set
    */
   public void setUsers(Map<String, UserDetails> users) {
      _users = users;
   }
}
